package com.simple.datax.conn.impl;

import com.simple.datax.conn.ConnectorPool;
import com.simple.datax.service.impl.SendStatusHandler;

/** 
 * @Title: ConnectorPoolManager.java 
 * @Package com.simple.datax.conn.impl 
 * @Description: 管理连接器池 
 * @author Joe Jin 
 * @date 2012-12-25 
 * @version V1.0 
 */
public class ConnectorPoolManager {
	public static final String CONN_SEND = "SEND";
	public static final String CONN_RECV = "RECEIVE";
	private static ConnectorPoolManager manager;
	private ConnectorPoolManager(){
		
	}
	
	/**
	 * Singleton
	 * @return ConnectorPoolManager instance
	 */
	public synchronized static ConnectorPoolManager getInstance() {
		if (manager==null) {
			manager = new ConnectorPoolManager();
		}
		return manager;
	}
	
	/**
	 * 根据连接器类型返回连接器池对象
	 * @param connType - (CONN_SEND, CONN_RECV)
	 * @return connector pool
	 */
	public ConnectorPool getConnectorPool(String connType, SendStatusHandler handler, SendThreadPoolExecutor poolExecutor) {
		if (CONN_SEND.equalsIgnoreCase(connType)) {
			return SendConnectorPool.getInstance(handler, poolExecutor);
		} else if (CONN_RECV.equalsIgnoreCase(connType)) {
			return ReceiveConnectorPool.getInstance();
		}
		return null;
	}
}
